package tianqi.controller.index;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;


import tianqi.entity.UserY;
import tianqi.service.index.impl.IndexServiceImpl;


@Controller
public class indexController {
	
	@Autowired
	private IndexServiceImpl indexServiceImpl;
	
	/**
	 * 查询 首页所有商品信息
	 * @param m
	 * @return
	 */
	@RequestMapping("/youge")
	public String showProduct(Model m){
		
		return indexServiceImpl.queryProduct(m);
	}
	
	/**
	 * 聊天室
	 * @param m
	 * @param req
	 * @return
	 */
	@RequestMapping("/maint")
	public String mail(Model m,HttpServletRequest req){
		UserY userY = (UserY) req.getSession().getAttribute("user");
		if (userY == null) {
			return "redirect:show.tq";
		}
		
		m.addAttribute("user", userY);
		return "serviceTQ";
	}
	
	/**
	 * 加载 首页轮播图
	 * @return
	 */
	@RequestMapping("/lunbo")
	@ResponseBody
	public String lunbo(){
		
		return indexServiceImpl.queryLunbo();
	}
	
	
	
	
	
}
